<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>日志管理</title>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<%@ include file="../jslib/jquerylib.jsp"%>
<script type='text/javascript'
	src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js"
	defer="defer"></script>
<script type="text/javascript"
	src="<%=request.getContextPath() %>/jslib/lhgdialog/lhgcore.lhgdialog.min.js?skin=mac"></script>
<link href="<%=request.getContextPath() %>/web/style/layout.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
   var selectId = "" ;
            $(document).ready(function(){
                $("#gridTable").jqGrid({
                    url:common_contextPath+'/searchLogList.action',
                    datatype: "json",
                    height: 240,
                    autowidth: true, 
                    colNames:['编号','组织名称', '用户名称','功能菜单名称','操作模块名称','日志事件','IP地址','日志时间'],
                    colModel:[
                        {name:'LOG_ID',index:'LOG_ID',key:true, width:60, sorttype:"int",hidden:true,hidedlg:true}, 
                        {name:'LOG_ORG_NAME',index:'LOG_ORG_NAME', width:120},
                        {name:'LOG_USER_NAME',index:'LOG_USER_NAME',width:70},
                        {name:'LOG_MODULE_NAME',index:'LOG_MODULE_NAME', width:120}, 
                        {name:'LOG_TYPE',index:'LOG_TYPE'},
                        {name:'LOG_LOGIN_EVENT',index:'LOG_LOGIN_EVENT', width:300},
                        {name:'LOG_LOGIN_IP',index:'LOG_LOGIN_IP', width:120},
                        {name:'LOG_CREATTIME',index:'LOG_CREATTIME', width:150}
                    ],   
                    shrinkToFit:false,
                    sortname:'LOG_ID',
                    sortorder:'desc',
                    viewrecords:true,
                    multiselect: true, // 是否显示复选框
                    multiboxonly : true, 
                    rownumbers: false,//显示行号
                    editable:true, 
                    rowNum:<%=session.getAttribute("SYS_PAGECOUNT")%>,
                    rowList:[15,20,50,200,500],
                    toolbar: [false,"top"],
                    jsonReader: {
                        root:"rows",        // 数据行（默认为：rows）
                        page: "page",   // 当前页
                        total: "total",  // 总页数
                        records: "records",  // 总记录数
                        repeatitems : false     // 设置成false，在后台设置值的时候，可以乱序。且并非每个值都得设
                    },
                    onSelectRow:function(rowid){
                       selectId = rowid;
                    },
                    prmNames:{rows:"rows",page:"page",sort:"sidx",order:"sord",search:"search"},
                    pager:"#gridPager",
                    caption: "日志管理列表"
                });
                 jQuery("#gridTable").jqGrid('navGrid','#gridPager',{add:false,edit:false,del:false,search:false,refresh:false});
                    jQuery("#gridTable").jqGrid('navButtonAdd','#gridPager',
                        {   
                        caption: "列状态",                          
                        title: "Reorder Columns",                           
                        onClickButton : function (){                               
                        jQuery("#gridTable").jqGrid('setColumns');                           
                        }
                    }); 
                    //doResize();
        });
            //执行大小
         function doResize() { 
               var ss = getPageSize(); 
                 $("#gridTable").jqGrid('setGridHeight', ss.WinH-140);              
                } 
             //查询
            function gridSearch(){
				selectId = "" ;
                var logModuleName =  jQuery("#logModuleName").val();
                var logOrgName = jQuery("#logOrgName").val(); 
                var logUserName = jQuery("#logUserName").val();
                var logLoginIp = jQuery("#logLoginIp").val();
                var logType = jQuery("#logType").val();
                var logStarTime =  jQuery("#logStarTime").val();
                var logEndTime =  jQuery("#logEndTime").val();

                 var params = {  
                            "logModuleName" : encodeURIComponent(logModuleName),                           
                            "logOrgName" : encodeURIComponent(logOrgName),
                            "logUserName" : encodeURIComponent(logUserName),
                            "logLoginIp" : encodeURIComponent(logLoginIp),
                            "logType" : encodeURIComponent(logType),
                            "logStarTime" : encodeURIComponent(logStarTime),
                            "logEndTime" : encodeURIComponent(logEndTime)
                  };
                
             var postData = $("#gridTable").jqGrid("getGridParam", "postData");
             $.extend(postData, params);  //(9)将postData中的查询参数覆盖为空值
            jQuery("#gridTable").jqGrid('setGridParam',
            {
                url:common_contextPath+'/searchLogList.action'
            }).trigger("reloadGrid", [{page:1}]); 
            }       
        
        
                 //查看
          function selectLog11(){
                  if(selectId == ""){
                   alert("请先选择记录!");  
                   return false;
                  }
                  var viewSend = 'getLogById.action?logId='+selectId;  
                  window.showModalDialog(viewSend,'650px','500px'); // 模式对话框的效果
                   //window.location.href=viewSend; //在同页面打开。
				   //打开新页面
			  	   //var strStyle="width=640, height=480, top=150, left=300,toolbar=yes, menubar=yes, scrollbars=yes, resizable=no, location=no, status=yes";
				   //var w1=window.open(viewSend,"viewSend",strStyle);
            }
            
         function selectLog(){
			var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
				if (!ids) {
				    alert("请先选择记录!");  
				    return false;  
				}
				if(ids.indexOf(",")!=-1){
					  alert("只能选择一条记录!");  
				        return false; 
				}
			var row = jQuery("#gridTable").jqGrid('getRowData',ids);//获取选中行.
			$.dialog({
			        id:'abcValue',
			        title:'日志信息查看', 
			        content:'url:<%=request.getContextPath() %>/system/getLogById.action?logId='+ids,
			        okVal:false,//确定按钮文字
			        cancelVal:false,//取消按钮文字
			        min:true, //是否显示最小化按钮
			        max:false,//是否显示最大化按钮
			        fixed:false,//开启静止定位
			        lock:true,//开启锁屏
			        focus:true,//弹出窗口后是否自动获取焦点（4.2.0新增）
			        time:null,//设置对话框显示时间
			        resize:true,//是否允许用户调节尺寸
			        drag:true,//是否允许用户拖动位置
			        cache:false,//是否缓存iframe方式加载的窗口内容页
			        width: '520px',
			        height: 420
		        });
		}
         function clearLog(){
        	 if(!confirm("确认要清空日志吗？")){
                 return false;
              }
        	 $.ajax({
 				type: "POST",
 				async: false,//取消异步提交
 				url: '<%=request.getContextPath() %>/system/clearLog.action',
 				dataType: "json",
 				success : function(data, textStatus) {  
 					if(data.ajaxResult=='success'){
 						alert("日志清除成功！");
 						refresh();
 					}else{
 						alert("日志清除失败！");
 					}
 				}
 			});
         }
            
            
             //清空
                function reset(){
                    jQuery("#logModuleName").val("");
                    jQuery("#logOrgName").val("");
                    jQuery("#logUserName").val("");
                    jQuery("#logLoginIp").val(""); 
                    jQuery("#logType").val("");
                    jQuery("#logStarTime").val(""); 
                    jQuery("#logEndTime").val(""); 
                }
                //刷新
                function refresh(){
                reset();
                 gridSearch();
                }
    function exportExcel(){
    		var ids= $("#gridTable").jqGrid("getGridParam", "selarrrow") + "";
    		if (!ids) {
		    alert("请先选择记录!");  
		    return false;  
			}
            var formId = jQuery("#formId").val();
            //window.location.href="eqAction!exportExcel.action?formId="+formId; 
            window.location.href="eqAction!exportExcelLog.action?ids="+ids; 
    }
    </script>

</head>


<body>
	<form action="" method="post"">
		<table width="100%" border="0" cellpadding="0" cellspacing="0"  class="formTableNew" style="width:100%;margin-bottom:0px">
			<tr>
				<td width="6%">日志时间：</td>
				<td width="18%">
				   <input id="logStarTime" name="logInfo.logStarTime" class='Wdate' onClick='WdatePicker();' style="width:150px;border:1px #8ec0e8 solid;" />
			    </td>
				<td width="6%" align="right">至：</td>
				<td width="18%">
				   <input id="logEndTime" name="logInfo.logEndTime" class='Wdate' onClick='WdatePicker();' style="width:150px; border:1px #8ec0e8 solid;" />
				</td>
				<td width="8%">功能菜单名称：</td>
				<td width="18%">
				   <input type="text" 	id="logModuleName" name="logInfo.logModuleName" value="" class="search_InputText" style="width:150px;" />
			    </td>
			    <td>
			      <input type="button" class="search_Btn" value="查 询" onclick="gridSearch()" />
			      <input type="button" class="search_Btn" value="清 空" onclick="reset()" />
			    </td>
			</tr>
			<tr>
				<td width="6%">用户名称：</td>
				<td width="18%">
				   <input 	type="text" id="logUserName" name="logInfo.logUserName" value="" class="search_InputText" style="width:150px;" />
			    </td>
			    <td width="6%" align="right">组织名称：</td>
			    <td width="18%">
			       <input type="text" id="logOrgName" name="logInfo.logOrgName" value="" class="search_InputText" style="width: 150px; " />
			    </td>
				<td width="6%">操作模块名称：</td>
				<td width="18%">
				    <input type="text" id="logType" name="logInfo.logType" class="search_InputText" style="width:150px; " />
				</td>
				<td></td>
			</tr>
		</table>

		<table style="width: 100%;" class="tableCont">
			<tr>
				<td><input id="log_view" type='button' value='查 看' onclick='selectLog()' class='search_Btn' />
					<input id="log_clear" type='button' value='清空日志' onclick='clearLog()' class='search_Btn' />
				    <input type='button' value='刷 新' onclick='refresh()' class='search_Btn' />
					<input id="export_user" type='button' value='导出excel' onclick='exportExcel()' class='button_b' /> </td>               
						 
			</tr>
			<tr>
				<td colspan="4">
					<table id="gridTable"></table>
					<div id="gridPager"></div>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
